<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<jsp:include page="/common.jsp"></jsp:include>
<script type="text/javascript">
	var i=0;
	function addTr(){
		i++;
		var trS = '<tr><td onclick="delTr(this)"><input type="button" value="-" class="btn"></td>';
		trS +='<input type="hidden" name="bom_sub.materiel.id'+i+'">';
		trS +='<input type="hidden" name="bom_sub.materiel.id">';
		trS +='<input type="hidden" name="bom_sub.id">';
		trS +='<td><input type="text" name="bom_sub.materiel.code'+i+'" class="input-small">';
		trS +='<a class="icon-search" onclick="goSearch('+i+',this)"></a></td>';
		trS +='<td><input type="text" name="bom_sub.materiel.name'+i+'" class="input-small""></td>';
		trS +='<td><input type="text" name="bom_sub.amount" class="input-small"></td>';
		trS +='<td><input type="text" name="bom_sub.loss" class="input-small"></td>';
		trS +='<td><input type="text" name="bom_sub.location" class="input-small"></td>';
		trS +='<td><input type="text" name="bom_sub.makeCode" class="input-small"></td>';
		trS +='<td><input type="text" name="bom_sub.bomlevel" class="input-small"></td>';
		trS +'</tr>';
	$('#tbody').append(trS);
	}
	
	function goSearch(i,obj){
		search_table_d('storem/warehouse?queryMateriel','bom_sub.materiel.id'+i+',bom_sub.materiel.code'+i+',bom_sub.materiel.name'+i,3,obj,'bom_sub.materiel.id');
	}
	function delTr(k){
		$(k).parent().remove();
	}
</script>
</head>
<body>
${title }
<form id="form" class="form-inline well" action="bom?save" method="post">
		<input type="hidden" name="id" value="${t.id }">
		<input type="hidden" name="materiel.id" value="${t.materiel.id }">
			<label><span class="span1">产品编号:</span>
				<input type="text" name="materiel.code" class="input-medium" value="${t.materiel.code }">
				<a class="icon-search" onclick="search_d('storem/warehouse?queryMateriel','materiel.id,materiel.code,materiel.name,,materiel.unit',1)"></a>
			</label>
			<label><span class="span1">产品名称:</span>
				<input type="text" name="materiel.name" class="input-medium" value="${t.materiel.name }">
			</label>
			<label><span class="span1">产品单位:</span>
				<input type="text" name="materiel.unit" class="input-medium" value="${t.materiel.unit }">
			</label>
			<label><span class="span1">制造工时:</span>
				<input type="text" name="makeDate" class="input-medium" value="${t.makeDate }">
			</label>
			<label><span class="span1.2">规格书编号:</span>
				<input type="text" name="standardno" class="input-medium" value="${t.standardno }">
			</label>
			
			<table class="table table-condensed"">
				<thead>
					<tr>
						<td style="width: 5px;"><input type="button" class="btn" value="+" onclick="addTr()"></td>
						<th>子件编号</th>
						<th>子件名称</th>
						<th>子件用量</th>
						<th>损耗率</th>
						<th>位号</th>
						<th>制成代码</th>
						<th>分阶</th>
					</tr>
				</thead>
				<tbody id="tbody">
					<c:forEach var="bom_sub" items="${bom_sub}">
						<tr>
							<td onclick="delTr(this)"><input type="button" value="-" class="btn"></td>
							<input type="hidden" name="bom_sub.materiel.id" value="${bom_sub.materiel.id }">
							<input type="hidden" name="bom_sub.id" value="${bom_sub.id }">
							<td><input type="text" name="code" class="input-small" value="${bom_sub.materiel.code}">
								<a class="icon-search" onclick=""></a>
							</td>
							<td><input type="text" name="bom_sub.materiel.name" class="input-small" value="${bom_sub.materiel.name}"></td>
							<td><input type="text" name="bom_sub.amount" class="input-small" value="${bom_sub.amount }"></td>
							<td><input type="text" name="bom_sub.loss" class="input-small" value="${bom_sub.loss }"></td>
							<td><input type="text" name="bom_sub.location" class="input-small" value="${bom_sub.location }"></td>
							<td><input type="text" name="bom_sub.makeCode" class="input-small" value="${bom_sub.makeCode }"></td>
							<td><input type="text" name="bom_sub.bomlevel" class="input-small" value="${bom_sub.bomlevel}"></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			
			<div class="control-group">
                <div class="controls">
                    <c:if test="${status==view}">
                        <button class="btn btn-primary" type="submit">保存</button>
                    </c:if>
                    <a class="btn btn-primary" onclick="go('produce/bom?list')">返回</a>
                </div>
         	</div>
	</form>
	<jsp:include page="/foot.jsp"></jsp:include>
</body>
</html>